package com.business_clean.viewmodel.request

import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.AppUtils
import com.business_clean.app.network.NetUrl
import com.business_clean.data.mode.appupdate.NewVersionInfo
import me.hgj.mvvmhelper.base.BaseViewModel
import me.hgj.mvvmhelper.ext.rxHttpRequest
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class MyCenterViewModel : BaseViewModel() {

    var newVersionInfo = MutableLiveData<NewVersionInfo>()


    /**
     * 检查是否有更新
     */
    fun requestCheckApp() {
        rxHttpRequest {
            onRequest = {
                newVersionInfo.value = RxHttp.get(NetUrl.CHECK_UPDATE_APP)
                    .add("version", "" + AppUtils.getAppVersionName())
                    .toResponse<NewVersionInfo>().await()
            }
        }
    }
}